package com.cxz.study.ddd_project.domain.biz.util;

import com.cxz.study.ddd_project.domain.biz.model.base.WhSerialNoRecordBO;
import com.cxz.study.ddd_project.infrastructure.model.dto.base.WhSerialNoRecordDTO;
import com.cxz.study.ddd_project.infrastructure.model.entity.base.WhSerialNoRecordDO;

import java.util.List;
import java.util.stream.Collectors;

/**
 * @className: BeanConvert
 * @author: ocxz1
 * @date: 2024/12/29 下午9:21
 * @Version: 1.0
 * @description: ddd_project1 bean转换
 */
public class BeanConvert {

    public static WhSerialNoRecordBO convertToWhSerialNoRecordBO(WhSerialNoRecordDO item) {
        if (item == null) {
            return null;
        }
        WhSerialNoRecordBO result = new WhSerialNoRecordBO();
        result.setId(item.getId());
        result.setOrderId(item.getOrderId());
        result.setStationNo(item.getStationNo());
        result.setSourceNo(item.getSourceNo());
        result.setSourceId(item.getSourceId());
        result.setSourceType(item.getSourceType());
        return result;
    }

    public static List<WhSerialNoRecordBO> convertToWhSerialNoRecordBOList(List<WhSerialNoRecordDO> item) {
        if (item == null) {
            return null;
        }
        return item.stream().map(BeanConvert::convertToWhSerialNoRecordBO).collect(Collectors.toList());
    }

    public static WhSerialNoRecordDTO convertToWhSerialNoRecordDTO(WhSerialNoRecordBO item) {
        if (item == null) {
            return null;
        }
        WhSerialNoRecordDTO result = new WhSerialNoRecordDTO();
        result.setId(item.getId());
        result.setOrderId(item.getOrderId());
        result.setStationNo(item.getStationNo());
        result.setSourceNo(item.getSourceNo());
        result.setSourceId(item.getSourceId());
        result.setSourceType(item.getSourceType());
        return result;
    }
}
